﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ext-test.aspx.cs" Inherits="ext_test" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>ext-测试页面</title>
    <style>
        .x-grid-row-over .x-grid-cell-inner
        {
            font-weight: bold;
        }
        .x-column-header-inner
        {
            height: 28px;
            background: #E7EBEF url(./images/header.png) repeat-x 0 0;
        }
    </style>
    <script>
        var template = '<span style="color:{0};">{1}</span>';

        var change = function (value) {
            return Ext.String.format(template, (value > 0) ? "green" : "red", value);
        };

        var pctChange = function (value) {
            return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
        };
        //导出EXCEL
        var exportData = function (format) {
            App.FormatType.setValue(format);
            var store = App.GridPanel1.store;

            store.submitData(null, { isUpload: true });
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Crisp" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout">
            <Items>
                <ext:Hidden ID="FormatType" runat="server" />
                <ext:GridPanel ID="GridPanel1" runat="server" Title="用户登录日志" TitleAlign="Center">
                    <TopBar>
                        <ext:Toolbar runat="server">
                            <Items>
                                <ext:TextField runat="server" ID="txtuser" FieldLabel="用户名" />
                                <ext:Button runat="server" Text="查询" OnDirectClick="BtnQureyUser" UI="Info">
                                    <DirectEvents>
                                        <Click>
                                            <EventMask ShowMask="true" Msg="加载中...">
                                            </EventMask>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Store>
                        <ext:Store ID="Store1" runat="server" PageSize="20" OnReadData="MyData_Refresh" OnSubmitData="Store1_Submit">
                            <Model>
                                <ext:Model ID="Model1" runat="server" IDProperty="usercode">
                                    <Fields>
                                        <ext:ModelField Name="用户编号" ServerMapping="usercode" />
                                        <ext:ModelField Name="用户名称" ServerMapping="username" />
                                        <ext:ModelField Name="客户端类型" ServerMapping="LoginType" />
                                        <ext:ModelField Name="登录时间" ServerMapping="LoginDateTime" DateFormat="M/d hh:mmtt" />
                                        <ext:ModelField Name="登录IP" ServerMapping="LoginIP" />
                                        <ext:ModelField Name="备注" ServerMapping="Remark" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel>
                        <Columns>
                            <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" Width="35" Text="序号" />
                            <ext:Column ID="Column2" runat="server" Text="用户编号" DataIndex="用户编号" Width="150" />
                            <ext:Column ID="Column3" runat="server" Text="用户名称" DataIndex="用户名称" Width="150">
                                <Renderer Fn="change" />
                            </ext:Column>
                            <ext:Column ID="Column4" runat="server" Text="客户端类型" DataIndex="客户端类型" Width="150">
                                <Renderer Fn="pctChange" />
                            </ext:Column>
                            <ext:DateColumn ID="DateColumn1" runat="server" Text="登录时间" DataIndex="登录时间" Width="150" />
                            <ext:Column ID="DateColumn2" runat="server" Text="登录IP" DataIndex="登录IP" Width="150" />
                            <ext:Column ID="DateColumn3" runat="server" Text="备注" DataIndex="备注" Width="150" />
                            <ext:CommandColumn ID="CommandColumn1" runat="server" Width="150">
                                <Commands>
                                    <ext:GridCommand Icon="Cross" CommandName="Delete" ToolTip-Text="删除" />
                                    <ext:GridCommand Icon="NoteEdit" CommandName="Edit" ToolTip-Text="编辑" />
                                    <ext:GridCommand Icon="Stop" CommandName="Stop" ToolTip-Text="停用" />
                                </Commands>
                                <Listeners>
                                    <%--<Command Handler="Ext.Msg.alert(command, record.data.company);" />--%>
                                    <%--<Command Fn="post"/>--%>
                                </Listeners>
                                <DirectEvents>
                                    <Command OnEvent="Command">
                                        <ExtraParams>
                                            <ext:Parameter Name="Id" Value="record.data.用户编号" Mode="Raw" />
                                            <ext:Parameter Name="command" Value="command" Mode="Raw" />
                                        </ExtraParams>
                                        <Confirmation BeforeConfirm="if (command=='Edit') return false;" ConfirmRequest="true"
                                            Message="确定要操作吗？" Title="消息提示" />
                                        <Confirmation />
                                    </Command>
                                </DirectEvents>
                            </ext:CommandColumn>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
                    </SelectionModel>
                    <BottomBar>
                        <ext:PagingToolbar ID="PagingToolbar1" runat="server">
                            <Items>
                                <ext:Label ID="Label1" runat="server" Text="每页显示:" />
                                <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                                <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                                    <Items>
                                        <ext:ListItem Text="10" />
                                        <ext:ListItem Text="20" />
                                        <ext:ListItem Text="50" />
                                        <ext:ListItem Text="100" />
                                    </Items>
                                    <SelectedItems>
                                        <ext:ListItem Value="20" />
                                    </SelectedItems>
                                    <Listeners>
                                        <Select Handler="#{GridPanel1}.store.pageSize = parseInt(this.getValue(), 10); #{GridPanel1}.store.reload();" />
                                    </Listeners>
                                </ext:ComboBox>
                                <ext:Button ID="Button2" runat="server" Text="导出Excel" Icon="PageExcel">
                                    <Listeners>
                                        <Click Handler="exportData('xls');" />
                                    </Listeners>
                                </ext:Button>
                            </Items>
                            <Plugins>
                                <ext:ProgressBarPager ID="ProgressBarPager1" runat="server" />
                            </Plugins>
                        </ext:PagingToolbar>
                    </BottomBar>
                </ext:GridPanel>
            </Items>
        </ext:Viewport>
    </div>
    </form>
</body>
</html>
